import request from '@/utils/request'
import type { GoodsQuery, Goods, UpdateFlag } from '@/types/goods'
import type { ApiRes } from '@/types/data'

// 获取商品列表
export const getGoodsList = (params: GoodsQuery) => {
  return request<ApiRes<{ total: number; items: Goods[] }>>({
    url: 'pro/list',
    params
  })
}

// 获取分类列表
export const getCategories = () => {
  return request<ApiRes<string[]>>({
    url: 'pro/getCategory'
  })
}

// 更改是否售卖、是否秒杀，是否推荐
export const updateFlag = (data: UpdateFlag) => {
  return request<{ code: number; message: string }>({
    url: 'pro/updateFlag',
    method: 'POST',
    data
  })
}
